using System;
using System.IO;

namespace SoftwareMonkeys.Scriptech.Projects
{
	public class ProjectAssemblyOutputter
	{
		static public void Output(string assemblyFile, string buildMode, string storeName, string groupName, string projectName, bool throwExceptionIfNotFound)
		{
			string projectDirectoryPath = ProjectFileNamer.GetProjectPath(storeName, groupName, projectName);
			
			string binDirectoryPath = Path.Combine(projectDirectoryPath, "bin");
			
			string modeDirectoryPath = Path.Combine(binDirectoryPath, buildMode);
			
			if (!Directory.Exists(modeDirectoryPath))
				Directory.CreateDirectory(modeDirectoryPath);
			
			string toFile = Path.Combine(modeDirectoryPath, Path.GetFileName(assemblyFile));
			
			if (File.Exists(assemblyFile))
				File.Copy(assemblyFile, toFile, true);
			else if (throwExceptionIfNotFound)
				throw new ArgumentException("Assembly file not found: " + assemblyFile);
		}
		
	}
}

